package com.bolt.support.spring.jpa.ext;

import org.hibernate.dialect.PostgreSQL10Dialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StandardBasicTypes;

/**
 * Created by Administrator on 2021/4/23.
 */
public class ExtPostgreSqlDialect extends PostgreSQL10Dialect {

    public ExtPostgreSqlDialect() {
        super();
        //registerFunction("array_agg", new StandardSQLFunction("array_agg", StandardBasicTypes.STRING));
        registerFunction( "array_agg", new SQLFunctionTemplate( StandardBasicTypes.STRING, "array_agg(distinct(?1))" ) );
        registerFunction( "array_to_string", new SQLFunctionTemplate( StandardBasicTypes.STRING, "array_to_string(?1,?2)" ) );
        registerFunction("instr", new SQLFunctionTemplate(StandardBasicTypes.STRING, "POSITION(?2 IN ?1)"));


    }
}

 